using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;
namespace BUS
{
    public enum TinhTrangSachBUSResult
    {
        OK ,
        DAOERROR
    }
    public class TinhTrangSach
    {
        public static TinhTrangSachBUSResult SelectAll(List<DTO.TinhTrangSach> ds)
        {
            string sql = "select * from TinhTrangSach";
            DAO.Interface dao = new DAO.TheLoaiSach();
            DataTable dt = dao.Select(sql);
            if (dt != null)
            {
                for (int i = 0 ; i < dt.Rows.Count ; i++)
                {
                    DTO.TinhTrangSach temp = new DTO.TinhTrangSach();
                    temp.MaTinhTrang = (int)dt.Rows[i].ItemArray[0];
                    temp.TenTinhTrang = dt.Rows[i].ItemArray[1].ToString();
                    ds.Add(temp);
                }
                return TinhTrangSachBUSResult.OK;
            }
            return TinhTrangSachBUSResult.DAOERROR;
        }
        public static string LayMaTinhTrangSach(string tenTinhTrang)
        {
            DAO.TinhTrangSach tts = new DAO.TinhTrangSach();
            return tts.LayMaTinhTrang(tenTinhTrang);
        }
    }
}
